#ifndef DOCTORWIDGET_H
#define DOCTORWIDGET_H

#include <QWidget>
#include <QJsonObject>
#include <QDateTime>
#include "../../../Common/models.h"
#include "../../../Common/protocol.h"

class QListWidget;

namespace Ui {
class DoctorWidget;
}

class DoctorWidget : public QWidget {
    Q_OBJECT
    
public:
    explicit DoctorWidget(const Doctor& doctor, QWidget *parent = nullptr);
    ~DoctorWidget();
    
private slots:
    void on_profileTab_clicked();
    void on_appointmentsTab_clicked();
    void on_chatTab_clicked();
    void on_attendanceTab_clicked();
    void on_notificationButton_clicked();  // 通知中心
    void onMessageReceived(MessageType type, const QJsonObject& data);
    void showPatientDetail(int patientId, int appointmentId);
    void showCreateRecord(const Doctor& doctor, const Patient& patient, int appointmentId, const QDateTime& appointmentTime);
    void showCreatePrescription(const Doctor& doctor, const Patient& patient, int appointmentId, int latestRecordId);
    
private:
    void loadDoctorInfo();
    void updateNotificationList(const QJsonArray& notifications);
    
    Ui::DoctorWidget *ui;
    Doctor m_doctor;
    QListWidget* m_notificationList;  // 通知列表
    int m_currentPatientId;      // 当前查看的患者ID
    int m_currentAppointmentId;  // 当前查看的预约ID
    int m_unreadNotificationCount;  // 未读通知数量
};

#endif // DOCTORWIDGET_H

